{extend name='layout/base'}
{block name='title'}商品管理-商品列表{/block}
{block name='left'}
{include file="layout/goodsMenu" /}
{/block}
{block name='right'}
<div class="page-header">
    <h1>商品列表</h1>
</div>
<div class="well">
    <form class="form-inline" method="get">
        <div class="form-group">
            <input type="text" class="form-control" name="key" placeholder="请输入关键字" value="{$key}">
        </div>
        <div class="form-group">
            <?php
                //读取set.php配置文件中的状态
                $config_status = config('set.goods_status');
                foreach ($config_status as $key => $value):
                    //保持选择状态
                    //将状态和$key强制转化成字符串来比较
                    $checked = (string)$key === (string)$status ? 'checked' : '';
            ?>
            <label class="radio-inline">
                <input type="radio" name="status" value="{$key}" {$checked}>{$value}
            </label>
            <?php endforeach?>  
        </div>
        <!--商品排序start-->
        <div class="form-group">
            <select class="form-control" name="orderby" id="orderby">
                <option value="goods_id_desc">默认排序</option>
                <option value="price_desc">价格↓</option>         
                <option value="price_asc">价格↑</option>                
                <option value="stock_number_desc">库存数量↓</option>
                <option value="stock_number_asc">库存数量↑</option>
            </select>      
        </div>
        <!--处理单选按钮保持状态-->
        <script type="text/javascript">
            $("#orderby").val("{$orderby}");
        </script>
        <!--商品排序end-->        
        <!--商品类别start-->
        <div class="form-group">
            <select class="form-control" name="category" id="category">
                <?php               
                    $config_status = config('set.category_status');
                    foreach($config_status as $k => $v):
                        $selected = (string)$k === (string)$category ? 'selected' : '';
                ?>
                <option value="{$k}" {$selected}>{$v}</option>
                <?php endforeach?>
            </select>      
        </div>
        <!--商品类别end-->
        <!--商品口味start-->
        <div class="form-group">
            <select class="form-control" name="taste" id="taste">
                <?php
                    $config_status = config('set.taste_status');
                    foreach($config_status as $k => $v):
                        $selected = (string)$k === (string)$taste ? 'selected' : '';
                ?>
                <option value="{$k}" {$selected}>{$v}</option>
                <?php endforeach?>           
            </select>      
        </div>
        <!--商品口味end-->
        <!--商品特色start-->
        <div class="form-group">
            <select class="form-control" name="features" id="features">
                <?php
                    $config_status = config('set.features_status');
                    foreach($config_status as $k => $v):
                        $selected = (string)$k === (string)$features ? 'selected' : '';
                ?>
                <option value="{$k}" {$selected}>{$v}</option>
                <?php endforeach?>                
            </select>      
        </div>
        <!--商品特色end-->
        <!--商品规格start-->
        <div class="form-group">
            <select class="form-control" name="size" id="size">
                <?php
                    $config_status = config('set.size_status');
                    foreach($config_status as $k => $v):
                        $selected = (string)$k === (string)$size ? 'selected' : '';
                ?>
                <option value="{$k}" {$selected}>{$v}</option>
                <?php endforeach?>                
            </select>      
        </div>
        <!--商品规格end-->                                
        <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
    </form>
</div>



<div class="table-responsive">
    <table class="table">
        <thead>
            <tr>
                <th>#</th>
                <th>标题</th>
                <th>标题图</th>
                <th>价格</th>
                <th>类别</th>
                <th>口味</th>
                <th>特色</th>
                <th>规格</th>
                <th>库存数量</th>
                <th>商品状态</th>
                <th>商品添加时间</th>
                <th>管理</th>
            </tr>
        </thead>
        <tbody>
            <?php
                foreach ($rows as $row) {                 
            ?> 
            <tr>
                <?php
                    $category = $row['category'];
                    $taste = $row['taste'];
                    $features = $row['features'];
                    $size = $row['size'];
                    $status = $row['status'];
                ?>
                <th scope="row">{$row['goods_id']}</th>
                <td>{$row['title']}</td>
                <td><img class="img-rounded" src="<?php echo thumb_url($row['image']);?>" width="100px" height="100px"></td>
                <td>{$row['price']}</td>
                <td><?php echo config('set.category_status')[$category];?></td>
                <td><?php echo config('set.taste_status')[$taste];?></td>
                <td><?php echo config('set.features_status')[$features]?></td>
                <td><?php echo config('set.size_status')[$size];?></td>
                <td>{$row['stock_number']}份</td>
                <td><?php echo config('set.goods_status')[$status];?></td>
                <td>{$row['create_time']}</td>
                <td>
                    <a href="<?php echo url('admin/admin.goods.GoodsAdd/index',['goods_id'=>$row['goods_id']]);?>" class="btn btn-primary btn-xs">编辑</a>
                    <a href="<?php echo url('admin/admin.goods.GoodsList/goodsDel',['goods_id'=>$row['goods_id']]);?>" class="btn btn-danger btn-xs" onclick="return confirm('确认删除吗？')">删除</a>
                </td>
            </tr>
            <?php } ?>          
        </tbody>
    </table>
</div>
<!--分页-->
<div class="row">   
    <div class="col-md-6 col-md-offset-4">  
        {$rows->render()}
    </div>  
</div>
{/block}